﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FullTextSearchList.aspx.cs" Inherits="ZX.WebApp.KM.FullTextSearch.FullTextSearchList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Styles/common.css" rel="stylesheet" type="text/css" />
    <link href="Styles/FullTextSearch.css" rel="stylesheet" type="text/css" />
    <link href="Script/jquery.pagination1.2/lib/pagination.css" rel="stylesheet" type="text/css" />

    <script src="Script/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Script/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Script/jquery.pagination1.2/lib/jquery.pagination.js" type="text/javascript"></script>
    <script src="Script/CommonJS.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="Styles/navbar/navbar.css" />
    <script src="Styles/navbar/jquery.flowMap.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
        <%--详细信息显示--%>
        <div class="FlowCharDiv_C" style=" display:block;">
            <div class="b d1 flowMap">
                <iframe frameborder="0" id="ShowdocumentIframe" width="100%" height="100%" src=""></iframe>
            </div>
            <div class="navbar">
                <div class="navbar-l"></div>
                <div class="navbar-r"></div>
                <div class="navbar-icon-right"><span class="togglebtn togglebtn-down"></span></div>
            </div>
        </div>


        <div style="margin-left:25px; margin-right:25px;">

<div id="appbar" style="text-align:center; margin-left:50px;">
    <div style="position: relative" id="topabar">
        <div class="ab_wrp">
            <div id="ab_name"><span>检索</span></div>
            <div>
                <div id="resultStats">找到约 0 条结果 <nobr>（用时 0.00 秒）&nbsp;</nobr></div>
            </div>
        </div>
    </div>

    <div style="clear: both; overflow: hidden; width:85%;">
        <div id="center_col">
            <div id="res">
                <div id="search">
                    <h2 class="hd"> 搜索结果</h2>
                    <div id="ires">
                        <ol>
                        <%--内容体--%>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
<!-- 这里显示分页 -->
    <div id="Pagination" class="pagination" style="text-align:center;"></div>
    </div>
        
</div>

</div>

 <script type="text/javascript">

        var PageSize = 10; //每页显示数量
        var PageCount = 0; //总数目
        var beforeload;
        var tempAction;
        var IsFirstLoad = true;
        var kmindex = "<%=KmIndex %>";
        var KmLoadFromOut = "<%=KmLoadFromOut %>";
        var searchOther = "no";

        $(document).ready(function () {

            searchOther = getQueryStringByName("SearchOther");
            if (searchOther == null || searchOther == undefined || searchOther == "") searchOther = "no";

            IsFirstLoad = true;
            beforeload = (new Date()).getTime();
            searchFun(0, IsFirstLoad);

            $(".FlowCharDiv_C").animate({ top: -500, opacity: 'hide' }, { duration: 0, queue: true });
            $(".TitleSearch,.SummarySearch").live("click", function () {
                var CryptographyValue = $(this).attr("CryptographyValue");
                var id = $(this).attr("DocumentID");
                postJson({
                    ajaxUrl: "FullTextSearchList.aspx",
                    postData: { 'Action': 'CheckRight', 'ResourceID': id, 'r': Math.random() },
                    callback: function (data) {
                        if (data.ErrorMsg == "yes") {
                            if (searchOther == "no") {
                                window.open(kmindex + "?KM_DATA=" + CryptographyValue);
                            }
                            else {
                                $(".FlowCharDiv_C").flowMap("show");
                                $("#ShowdocumentIframe").attr("src", KmLoadFromOut + "?KM_DATA=" + CryptographyValue);
                            }
                        }
                        else {
                            alert("没有权限查看该文档，请联系管理员");
                        }
                    }
                });
            });
        });

        //输入页码索引
        var searchFun = function (PageIndex, IsFirstLoad) {
            if (PageIndex == 0) PageIndex = 1;
            var key = getQueryStringByName("key");
            var fullKey = getQueryStringByName("fullKey");
            if (key.length > 0) tempAction = "GetSearchResultByKey";
            else tempAction = "GetSearchResultByAny";
            var url = "FullTextSearchList.aspx?Action=" + tempAction + "&PageIndex=" + PageIndex + "&PageSize=" + PageSize + "&Key=" + key + "&FullKey=" + fullKey;
            url = encodeURI(url);
            ajax({
                type: "get",
                ajaxUrl: url,
                loading: '数据加载中...',
                success: function (data) {
                
                    PageCount = data.TotalCount;
                    if (IsFirstLoad) LoadPagination();

                    loadHtmlForPageIndex(data);

                    if (IsFirstLoad) {
                        var afterload = (new Date()).getTime();
                        secondes = (afterload - beforeload) / 1000;
                        $("#resultStats").html("找到约 " + PageCount + " 条结果 <nobr>（用时 " + secondes + " 秒）&nbsp;</nobr>")
                    }
                }
            });
        };

        var LoadPagination = function () {// 创建分页
            $("#Pagination").pagination(PageCount, {
                num_edge_entries: 3, //起始与结束点的数目
                num_display_entries: 5, //中间显示数量
                callback: pageselectCallback, //回调函数
                items_per_page: PageSize, //每页显示数量
                prev_text: "前一页",
                next_text: "后一页"
            });
        }

        var loadHtmlForPageIndex = function (data) {
            if (data == null || data == undefined) return;
            var searchList = $("#ires");
            searchList.html("");
            $.each(data.Result, function (i) {
                var obj = data.Result[i];
                if (obj != null || obj != undefined) {
                    var _tempHtml = "";
                    _tempHtml += "   <li>";
                    _tempHtml += "         <div DocumentID="+obj.ID+" title=" + obj.Title + " >";
                    _tempHtml += "             <h3 class=\"r\"><a href=\"javascript:void(0)\" CryptographyValue=" + obj.CryptographyValue + " DocumentID=" + obj.ID + " DocumentTitle=" + obj.Title + " class='TitleSearch'><strong>" + obj.Title + "</strong></a></h3>";
                    _tempHtml += "             <div>";
                    _tempHtml += "                 <span class=\"st\">" + $.trim(obj.Summary) + "...<a class='SummarySearch' DocumentID=" + obj.ID + " href=\"javascript:void(0)\" CryptographyValue=" + obj.CryptographyValue + " DocumentID=" + obj.ID + " DocumentTitle=" + obj.Title + " title=\"点击查看更多\">详情</a></span>";
                    _tempHtml += "                 <div class=\"f\">";
                    _tempHtml += "                     <cite>位置:" + obj.Path + "</cite>";
                    _tempHtml += "                     <cite>创建人：" + obj.PublishBy + "</cite>";
                    _tempHtml += "                     <cite>创建时间：" + obj.PublishTime + "</cite>";
                    _tempHtml += "                 </div>";
                    _tempHtml += "              </div>";
                    _tempHtml += "         </div>";
                    _tempHtml += "   </li>";
                    searchList.append(_tempHtml);
                }
                else {
                    searchList.append("<span style='color:red;'></span>");
                }
            });
        };

        var cr = function (id, title) {
            postJson({
                ajaxUrl: "FullTextSearchList.aspx",
                postData: { 'Action': 'CheckRight', 'ResourceID': id, 'r': Math.random() },
                callback: function (data) {
                    var url = "Client/Document/ShowDocument.aspx?ID=" + id + "&IsFullSearch=YES&r=" + Math.random();
                }
            });
        }

        function pageselectCallback(page_index, jq) {
            if (IsFirstLoad) { IsFirstLoad = false; return; }
            searchFun(page_index + 1, false);

            //阻止单击事件
            return false;
        }

        var MyRedirect = function (id) {
            L_ID = id;
            L_NAME = "详细信息";
            L_URL = "Client/Document/Document.aspx?ID=" + id;
            parent.Redirect();
        }
    </script>

    </form>
</body>
</html>
